#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
int tmp1;
struct node{
    db v,ad;
    int st;
}a[100000];
int b[100000];
int c1,c2;
int left;
bool vis[100000];
struct nnode{
    int st,ed;
}c[100000];
int d[100000];
int n,m,L,V,_;
bool checkcheck(int mi)
{
    int cnt=0;

    for(int i=1;i<=tmp1;i++)
    {
        if(c[i].st>c[i-1].ed) cnt++;
    }
    if(cnt<=mi) return 1;
    else return 0;
}
void check()
{
    int l=0,r=m-1,mi,t;
    while(l<=r)
    {
        mi=(l+r)/2;
        if(checkcheck(mi))
        {

            t=mi;l=mi+1;

        }
        else{
            r=mi-1;
        }
    }
    cout<<t-1<<endl;
}
bool cmp(nnode x,nnode y)
{

    return x.st<y.st;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>_;
    while(_--)
    {
        memset(vis,0,sizeof(vis));
        int fans=0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i].st>>a[i].v>>a[i].ad;
        }
        for(int i=1;i<=m;i++)
        {
            cin>>b[i];
        }
        sort(b+1,b+m+1);
        int pos=m+1,pos1=0,pos2=0;
        tmp1=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i].st>b[m])
            {
                //cout<<i<<" is ok"<<endl;
                continue;
            }
            else
            {
                    if(a[i].ad==0)
                    {
                        if(a[i].v<=V) { continue;}
                        else{
                            c1++;
                            int k=upper_bound(b+1,b+m+1,a[i].v)-b;
                            //cout<<"pos:"<<pos<<endl;
                           // cout<<"b:"<<b[pos]<<endl;
                        }
                    }
                    else{
                        db dis=(1.00*V*V-1.00*a[i].v*a[i].v)/(2*1.00*a[i].ad);
                        dis+=a[i].st;
                        //cout<<dis<<endl;
                       // if(dis<b[1])
                       // {
                        //    continue;
                      //  }
                      //else{
                            if(a[i].ad>0)
                            {
                                 c1++;
                                 int k=upper_bound(b+1,b+m+1,dis)-b;
                                 pos=min(pos,k);
                                 //cout<<"pos:"<<pos<<endl;
                                    //cout<<"b:"<<b[pos]<<endl;
                            }
                            else{
                               // cout<<dis<<" "<<a[i].st<<endl<<endl;
                                 int k=upper_bound(b+1,b+m+1,dis)-b;
                                 pos1=k-1;
                                 //cout<<"pos:"<<pos<<endl;


                                int kk=upper_bound(b+1,b+m+1,a[i].st)-b;
                                 pos2=kk-1;
                                 if(pos2==b[m]||pos1==b[m]) continue;
                                 c[++tmp1].st=pos2,c[tmp1].ed=pos1;
                                if(pos1==pos2&&pos1!=b[pos1]&&pos2!=b[pos2])
                                {
                                   // cout<<i<<" is ok"<<endl;
                                    continue;
                                }
                                else{
                                   c1++;
                                }
                            }

                        //}
                    }
            }
           // cout<<"hi"<<endl;



        }
        sort(c+1,c+tmp1+1,cmp);
        //for(int i=1;i<=tmp1;i++)
        //{
        //    cout<<c[i].st<<" "<<c[i].ed<<endl;
       // }
        cout<<c1<<" ";
        check();
    }


    return 0;
}
